package cn.teamwork.ssm.mapper;

import cn.teamwork.ssm.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.omg.CORBA.PUBLIC_MEMBER;

import java.util.List;

public interface UserMapper {
    @Select("select id,`username`,`disabled` from `hbeu_user` where deleted=0 LIMIT #{o},#{l}")
    public List<User> find(@Param("o") int offset,@Param("l") int limit);

    @Select("select count(1) from `hbeu_user` where deleted=0")
    public Long count();

    @Select("select count(1) from `hbeu_user` where username=#{u}")
    public boolean exists(@Param("u") String username);

    @Select("select id from `hbeu_user` where username=#{u} and `password`=#{p}")
    public Long findIDByUsernameAndPassword(@Param("u") String username,@Param("p") String password);

    @Select("select count(1) from `hbeu_user` where id=#{i} and `deleted`=1")
    public boolean isDelected(@Param("i")Long id);

    @Select("select count(1) from `hbeu_user` where id=#{i} and `disabled`=1")
    public boolean isDisabled(@Param("i")Long id);

    @Select("insert into `hbeu_user`(`username`,`name`) values(#{u},#{n})")
    public void addUser(@Param("u") String username,@Param("n") String name);


}